defmodule GiomWeb.Router do
  use GiomWeb, :router

  pipeline :browser do
    plug :accepts, ["html"]
    plug :fetch_session
    plug :fetch_flash
    plug :protect_from_forgery
    plug :put_secure_browser_headers
    
  end

  pipeline :api do
    plug :accepts, ["json"]
    plug :fetch_session #
    plug :protect_from_forgery # csrf koruması için api pipeline bu eklenir + fetch_Session
  end
  
  pipeline :api_public do
    plug :accepts, ["json"]
  end

  scope "/", GiomWeb do
    pipe_through :browser # Use the default browser stack

    get "/", PageController, :index
    resources "/stocks", StockController
    resources "/ists", IstController
    post "/ists/get_stockname", IstController, :get_stockname
    resources "/points", PointController
    resources "/ptrans", PtransController
    resources "/stocktrans", StocktransController
    resources "/deneme", DenemeController
  end

  # Other scopes may use custom stacks.
  scope "/api", GiomWeb do
    pipe_through :api
    post "/stock/get_stockname", StockController, :get_stockname
  end
  
  # farklı scopelar kullanarak, routelarımızı ayırabiliriz.
  # public api de csrf koruması kullanılmıyor mesela.
  scope "/api", GiomWeb do
    pipe_through :api_public
    post "/public/stock/get_stockname", StockController, :get_stockname
  end
  
end
